package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zog {
   String a;
   String b;
   ArrayList c = new ArrayList();
   HashMap d = new HashMap();
   HashMap e = new HashMap();
   zol f;
   ArrayList g = new ArrayList();
   ArrayList h = new ArrayList();
   boolean i = false;
   boolean j = false;
   boolean k = false;
   boolean l = false;
   private int m = 0;
   private ArrayList n = new ArrayList();

   zog() {
   }

   zog(zol var1) throws Exception {
      this.f = var1;
      this.l = this.f.a.g != null && this.f.a.g.d != null;
      if (this.a(this.f, this.f.a.getShapes())) {
         this.b = "vmlDrawing" + zase.y(this.f.e.a()) + ".vml";
         String var2 = "../drawings/" + this.b;
         this.a = this.f.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing", var2).c;
      }

   }

   private boolean a(zol var1, ShapeCollection var2) throws Exception {
      boolean var3 = var1 != null && this.l;
      Iterator var4;
      if (var1 != null && var1.a.g != null && var1.a.g.q.size() > 0) {
         var4 = var1.a.g.q.iterator();

         while(var4.hasNext()) {
            zqe var5 = (zqe)var4.next();
            com.aspose.cells.b.a.a.ze.a(this.c, (Object)var5);
         }
      }

      if (var1 != null && var1.a.getType() == 2) {
         Chart var7 = var1.a.getCharts().get(0);
         if (var7.l() != null && var7.l().getCount() > 0 && this.a((zol)null, (ShapeCollection)var7.l())) {
            var3 = true;
         }
      } else {
         var4 = var2.iterator();

         while(var4.hasNext()) {
            Shape var8 = (Shape)var4.next();
            ++this.m;
            switch(var8.getMsoDrawingType()) {
            case 5:
               Chart var6 = ((ChartShape)var8).a();
               if (var6.l() != null && var6.l().getCount() > 0 && this.a((zol)null, (ShapeCollection)var6.l())) {
                  var3 = true;
               }
            case 6:
            case 9:
            case 10:
            case 13:
            case 15:
            case 21:
            case 22:
            case 23:
            default:
               break;
            case 7:
            case 11:
            case 12:
            case 14:
            case 16:
            case 17:
            case 18:
            case 19:
               this.a(this.m, new zoj(var8));
               this.j = true;
               this.b(var8);
               var3 = true;
               break;
            case 8:
               if (this.a(this.m, (Picture)var8)) {
                  var3 = true;
               }
               break;
            case 20:
               if (!var8.U()) {
                  this.a(this.m, new zoj(var8));
                  this.b(var8);
                  this.j = true;
                  var3 = true;
               }
               break;
            case 24:
               this.a(var8, this.m);
               var3 = true;
               break;
            case 25:
               this.a(this.m, new zoj(var8));
               this.b(var8);
               var3 = true;
               this.k = true;
            }
         }
      }

      return var3;
   }

   private void a(int var1, zoj var2) {
      if (this.f.w.get(var1 - 1) == null && var2.d.S()) {
         zoh var3 = this.a(var2.d.getGroup());
         com.aspose.cells.b.a.a.ze.a(var3.a, (Object)var2);
      } else {
         com.aspose.cells.b.a.a.ze.a(this.h, (Object)var2);
      }

   }

   private zoh a(GroupShape var1) {
      Iterator var2 = this.n.iterator();

      zoh var3;
      do {
         if (!var2.hasNext()) {
            zoh var4 = new zoh(var1);
            com.aspose.cells.b.a.a.ze.a(this.n, (Object)var4);
            this.a(-1, (zoj)var4);
            return var4;
         }

         var3 = (zoh)var2.next();
      } while(var3.d != var1);

      return var3;
   }

   private boolean a(Shape var1, int var2) throws Exception {
      OleObject var3 = (OleObject)var1;
      zoi var4 = new zoi(var1);
      if (var3.e() != 0) {
         var4.b = (String)this.f.e.f.get(var3.e());
         if (var4.b != null) {
            var4.a = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "../media/" + var4.b);
         }
      }

      this.a(var2, (zoj)var4);
      this.i = true;
      zob var5 = new zob();
      var5.a = var3;
      var5.b = var4.g;
      if (!var3.isLink()) {
         if (var3.l()) {
            var5.e = "oleObject_" + this.f.a.getIndex() + "_" + var2 + ".bin";
            var5.c = this.f.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject", "../embeddings/" + var5.e).c;
         } else {
            String var6 = var3.getObjectSourceFullName();
            if (var6 == null || "".equals(var6)) {
               String var7 = FileFormatUtil.a(var3.getFileFormatType(), ".bin");
               var6 = "oleObject_" + this.f.a.getIndex() + "_" + var2 + var7;
            }

            var5.e = com.aspose.cells.b.a.d.zk.b(var6);
            if (var3.g()) {
               var5.c = this.f.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package", "../embeddings/" + var5.e).c;
            } else {
               var5.c = this.f.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject", "../embeddings/" + var5.e).c;
            }
         }
      }

      if (var4.b != null) {
         var5.d = this.f.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "../media/" + var4.b).c;
      }

      com.aspose.cells.b.a.a.ze.a(this.f.o, (Object)var5);
      return true;
   }

   private boolean a(int var1, Picture var2) {
      if (var2.g != null && (var2.g.b != null || var2.g.a != null)) {
         if (!this.d.containsKey(var2.b())) {
            String var5 = "../media/" + (String)this.f.e.f.get(var2.b());
            String var4 = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", var5);
            this.d.put(var2.b(), var4);
         }

         return true;
      } else {
         zoi var3;
         if (var2.ac() == null && var2.x == null) {
            if (var2.b != null) {
               this.i = true;
               var3 = new zoi(var2);
               if (var2.b() != 0) {
                  var3.b = (String)this.f.e.f.get(var2.b());
                  if (var3.b != null) {
                     var3.a = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "../media/" + var3.b);
                  }
               }

               this.a(var1, (zoj)var3);
               return true;
            } else {
               return false;
            }
         } else {
            var3 = new zoi(var2);
            if (var2.b() != 0) {
               var3.b = (String)this.f.e.f.get(var2.b());
               if (var3.b != null) {
                  var3.a = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "../media/" + var3.b);
               }
            }

            this.a(var1, (zoj)var3);
            if (var2.x != null) {
               var2.x.b = var3.g;
               var3.h = "#\u0000t201";
               this.j = true;
            } else {
               this.i = true;
            }

            return true;
         }
      }
   }

   private void b(Shape var1) throws Exception {
      byte[] var2 = var1.getFillFormat().getImageData();
      if (var2 != null) {
         zom var3 = new zom();
         var3.a = var2;
         var3.b = zase.a("image", this.f.e.d(), var2);
         var3.d = var1;
         com.aspose.cells.b.a.a.ze.a(this.g, (Object)var3);
         var3.c = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "../media/" + var3.b, (String)null);
      }
   }

   String a(Shape var1) {
      Iterator var2 = this.g.iterator();

      zom var4;
      do {
         if (!var2.hasNext()) {
            return null;
         }

         Object var3 = var2.next();
         var4 = (zom)var3;
      } while(var4.d != var1);

      return var4.c;
   }

   String a(String var1, String var2) {
      String var3 = "rId" + this.a();
      zqe var4 = new zqe(var3, var1, var2, (String)null);
      com.aspose.cells.b.a.a.ze.a(this.c, (Object)var4);
      return var3;
   }

   String a(String var1, String var2, String var3) {
      String var4 = "rId" + this.a();
      zqe var5 = new zqe(var4, var1, var2, var3);
      com.aspose.cells.b.a.a.ze.a(this.c, (Object)var5);
      return var4;
   }

   private int a() {
      int var1 = this.c.size();
      int var2 = this.c.size();

      for(int var3 = 0; var3 < var2; ++var3) {
         zqe var4 = (zqe)this.c.get(var3);

         try {
            int var5 = zase.C(var4.c.substring(3));
            if (var5 > var1) {
               var1 = var5;
            }
         } catch (Exception var6) {
            ;
         }
      }

      return var1 + 1;
   }
}
